﻿//using System;
//using Brouteforce.managers;
//using Microsoft.Xna.Framework;

//namespace Brouteforce.gameObjs {

//    public class Camera {
//        /// <summary>
//        /// determine the width that will result in movement when the mouse is hovering on it
//        /// </summary>
//        private const int ScreenMovmentPadding = 40;

//        private const float MoveSpeed = 300;
//        private readonly int _maxNumberOfXTilesToDraw;
//        private readonly int _maxNumberOfYTilesToDraw;
//        public static String Msg = "";

//        public Location ViewingLocation;
//        private Rectangle _cameraBounds;


//        public Camera(Rectangle viewport) {
//            ViewingLocation = new Location(viewport);
//            _maxNumberOfXTilesToDraw = (int)(viewport.Width / WorldManager.TileW + 1);
//            _maxNumberOfYTilesToDraw = (int)(viewport.Height / WorldManager.TileH + 1);
//            _cameraBounds = viewport;
//        }

//        public void MoveLeft() {
//            ViewingLocation.Velocity.X = -MoveSpeed;
//        }

//        public void MoveRight() {
//            ViewingLocation.Velocity.X = MoveSpeed;
//        }

//        public void MoveUp() {
//            ViewingLocation.Velocity.Y = -MoveSpeed;
//        }

//        public void MoveDown() {
//            ViewingLocation.Velocity.Y = MoveSpeed;
//        }

//        public void Update() {
//            if (_cameraBounds.Contains(InputManager.CurMouseX, InputManager.CurMouseY)) {
//                if (InputManager.CurMouseX <= ScreenMovmentPadding) {
//                    MoveLeft();
//                }
//                if (InputManager.CurMouseX >= ViewingLocation.Position.Width - ScreenMovmentPadding) {
//                    MoveRight();
//                }
//                if (InputManager.CurMouseY <= ScreenMovmentPadding) {
//                    MoveUp();
//                }
//                if (InputManager.CurMouseY >= ViewingLocation.Position.Height - ScreenMovmentPadding) {
//                    MoveDown();
//                }
//            }

//            ViewingLocation.LinearMove();
//            ViewingLocation.Velocity.X = 0;
//            ViewingLocation.Velocity.Y = 0;

//            if (!ViewingLocation.IsInside(WorldManager.WorldRect))
//                ViewingLocation.PushInto(WorldManager.WorldRect);

//        }

//        public void Draw() {
//            var world = WorldManager.World;

//            var firstTileX = Math.Floor((double)ViewingLocation.OnScreenX / WorldManager.TileW);
//            var firstTileY = Math.Floor((double)ViewingLocation.OnScreenY / WorldManager.TileH);

//            var numberOfXTiles = Math.Min(_maxNumberOfXTilesToDraw,
//                                          WorldManager.World.GetLength(0) - firstTileX);

//            var numberOfYTiles = Math.Min(_maxNumberOfYTilesToDraw,
//                                          WorldManager.World.GetLength(1) - firstTileY);

//            //Draw tiles
//            for (int x = 0; x < numberOfXTiles; x++) {
//                for (int y = 0; y < numberOfYTiles; y++) {
//                    WorldManager.GetTileAt((int)(x + firstTileX), (int)(y + firstTileY)).Draw(ViewingLocation.OnScreenX, ViewingLocation.OnScreenY);
//                }
//            }

//            //Draw players
//            for (int x = 0; x < numberOfXTiles; x++) {
//                for (int y = 0; y < numberOfYTiles; y++) {
//                    WorldManager.GetTileAt((int)(x + firstTileX), (int)(y + firstTileY)).DrawPlayers(ViewingLocation.OnScreenX, ViewingLocation.OnScreenY);
//                }
//            }

//        }

//        /// <summary>
//        /// return the tile x,y (on the world map) that is located in the given position on the screen - if no such tile will 
//        /// return (vector| x=-1, y=-1)
//        /// </summary>
//        /// <param name="x"></param>
//        /// <param name="y"></param>
//        /// <returns></returns>
//        public Vector2 GetTileAtScreenPosition(int x, int y) {
//            var tileX = Math.Floor((double)(ViewingLocation.Position.X + x) / WorldManager.TileW);
//            var tileY = Math.Floor((double)(ViewingLocation.Position.Y + y) / WorldManager.TileH);

//            if (tileX > WorldManager.TilesX || tileY > WorldManager.TilesY) {
//                return new Vector2(-1, -1);
//            }

//            return new Vector2((float)tileX, (float)tileY);
//        }
//    }
//}
